/*
 * Copyright [2010] [GP Software]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * PersonDao.java | Created on Mar 31, 2010
 */
package org.gp.dbtest.core.dao;

import org.gp.dbtest.core.model.Person;

import java.sql.SQLException;

/**
 * Data access object for person
 *
 * @author Paul Augustine C. Mendoza
 */
public interface PersonDao {

    /**
     * Creates a person
     *
     * @param p the person to create
     * @throws SQLException if creation fails
     */
    void create(Person p) throws SQLException;

    /**
     * Retrieves a person
     *
     * @param id the id of the person to retrieve
     * @return the person retrieved
     * @throws SQLException if retrieval fails
     */
    Person getById(Integer id) throws SQLException;

    /**
     * Updates a person's name
     *
     * @param id      the id fo the person to update
     * @param newName the new name of the person
     * @return the count of affected records
     * @throws SQLException if the update fails
     */
    int updateNameById(Integer id, String newName) throws SQLException;

    /**
     * Deletes a person
     *
     * @param id the record if of the person to delete
     * @return the count of affected records
     * @throws SQLException if the delete fails
     */
    int deleteById(Integer id) throws SQLException;
}
